import { reqGetIndex } from "@/api";
const state = {
  initData: {},
};
const actions = {
  // 获取首页数据
  async getIndexData({ commit }) {
    const result = await reqGetIndex();
    // console.log(result);
    if (result.code === 200) {
      //   console.log(result);
      commit("init", result.indexData);
    }
  },
};
const mutations = {
  init(state, value) {
    state.initData = value;

    // console.log(state.initData);
  },
};
const getters = {
  newsList(state) {
    return state.initData.newsList || [];
  },
  recommendAuthor(state) {
    return state.initData.recommendAuthor || [];
  },
};
export default {
  state,
  actions,
  mutations,
  getters,
};
